package com.example.fujia.androidapp.view.fragment;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.fujia.androidapp.R;
import com.example.fujia.androidapp.activity.BlockActivity;
import com.example.fujia.androidapp.tools.Tools;
import com.example.fujia.androidapp.view.block.MyImageView;

/**
 * Created by fujia on 2016/6/13.
 */
public class BlockFragment extends Fragment {
    private View view;

    // 版区UI
    private MyImageView myImageView01;
    private MyImageView myImageView02;
    private MyImageView myImageView03;
    private MyImageView myImageView04;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        this.view = inflater.inflate(R.layout.fg_block, container, false);

        this.setBlock();

        return this.view;
    }

    /**
     * 板块初始化及绑定
     * */
    private void setBlock(){
        if (!Tools.objectIsNullOrNot(this.view)){
            this.myImageView01 = (MyImageView) this.view.findViewById(R.id.MyImageView01);
            this.myImageView02 = (MyImageView) this.view.findViewById(R.id.MyImageView02);
            this.myImageView03 = (MyImageView) this.view.findViewById(R.id.MyImageView03);
            this.myImageView04 = (MyImageView) this.view.findViewById(R.id.MyImageView04);

            this.myImageView01.setOnClickIntent(new MyImageView.OnViewClickListener() {
                @Override
                public void onViewClick(MyImageView view) {
                    Intent intent = new Intent(getActivity(), BlockActivity.class);
                    intent.putExtra("blockId", "1");
                    startActivity(intent);
                }
            });

            this.myImageView02.setOnClickIntent(new MyImageView.OnViewClickListener(){
                @Override
                public void onViewClick(MyImageView view) {
                    Intent intent = new Intent(getActivity(), BlockActivity.class);
                    intent.putExtra("blockId", "2");
                    startActivity(intent);
                }
            });

            this.myImageView03.setOnClickIntent(new MyImageView.OnViewClickListener(){
                @Override
                public void onViewClick(MyImageView view) {
                    Intent intent = new Intent(getActivity(), BlockActivity.class);
                    intent.putExtra("blockId", "3");
                    startActivity(intent);
                }
            });

            this.myImageView04.setOnClickIntent(new MyImageView.OnViewClickListener(){
                @Override
                public void onViewClick(MyImageView view) {
                    Intent intent = new Intent(getActivity(), BlockActivity.class);
                    intent.putExtra("blockId", "4");
                    startActivity(intent);
                }
            });
        }
    }

}
